package com.example.demo;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

/**
 * @author KUN
 * 环境属性值
 */
public class SystemRecognize {

    public static Properties props;

    static{
        props = System.getProperties();
    }

    /**
     * 获取系统的名称
     * @return
     */
    public static String getOSName(){
        return props.getProperty("os.name");
    }

    /**
     * 获取系统的架构
     * @return
     */
    public static String getOSArch(){
        return props.getProperty("os.arch");
    }

    /**
     * 获取系统的文件分隔符
     * @return
     */
    public static String getFileSeparator(){
        return props.getProperty("file.separator");
    }

    /**
     * 获取系统的属性值
     * @return
     */
    public static String getValue(String propertyName){
        return props.getProperty(propertyName);
        // return System.getProperty(propertyName);
    }

    public static void main(String[] args) {
        System.out.println(getOSName());
        System.out.println(getFileSeparator());
        System.out.println(getOSArch());
        if("\\".equals(getFileSeparator())){
            System.out.println("S");
        }
        String str = "o";
        if(!"".equals(str)){
            System.out.println("s");
        }
        System.out.println(str.length());

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String clrq = "2000-09-09";
        String hzrq = "2002-08-08";
        try {
            Date d_clrq = sdf.parse(clrq);
            Date d_hzrq = sdf.parse(hzrq);
            if(d_clrq.compareTo(d_hzrq) == -1){
                System.out.println("成立日期必须大于准和日期");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }


    }

}
